<template>
	<view class="page-container flex flex-col items-center">
		<view class="h-110"></view>
        <image :src="utils.imgFormat('/profile/image/bg1.png')" class="welcome-bg" mode="aspectFill"></image>
		<view class="h-200"></view>
	   <view class="page-body flex flex-col items-center justify-center">
            <view class="confirm-btn" :class="loading?'animate__animated animate__tada':'animate_1'" @click="toPath">开始练习</view>
	   </view>
	</view>
</template>

<script setup>
	import {ref} from "vue";
	import {onLoad,onUnload} from '@dcloudio/uni-app'
	import utils from '@/utils/utils.js'
	import useUserStore from '@/store/user.js'
    import {customer} from "@/api";
	const userStore = useUserStore()
    const loading = ref(false)

	const toPath = () => {
    uni.switchTab({
        url: '/pages/index/index'
      })
      return
    if(!userStore.token || userStore.user?.avatar){
      uni.redirectTo({
        url: '/pages/index/index'
      })
      return
    }
    customer.isLogin().then(res => {
      if(!res.avatar || !res.nickname) {

      }
    }).catch(err => {

    })
  }
	onLoad(() => {
		setTimeout(() => {
			loading.value = true
		}, 1500)
	})
</script>

<style lang="scss" scoped>
.welcome-bg{
	width: 240rpx;
	height: 232rpx;
}
.confirm-btn{
	width: 280rpx;
    height: 98rpx;
    line-height: 98rpx;
    background: linear-gradient(to bottom , #034995 0%, #005FC6 100%);
    border-radius: 8rpx;
    text-align: center;
    color: #fff;
    font-size: 36rpx;
}
.animate_1{
	animation: rise 1.5s ease-out; // 添加动画
}
/* 定义动画 */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(500rpx);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

</style>